<template>
  <a-modal :title="`只显示用户/一番赏/福袋/任意门  的更新记录(新增,删除之类的不显示)`" style="top: 100px;" :visible="true" width="1000px" @cancel="handleCancel">
    <a-table class="product-table" :rowKey="row => row.id" :dataSource="list" bordered :pagination="pagination" size="small">
      <a-table-column title="操作" width="30px">
        <template slot-scope="row">
          <span>
            {{row.describe}}
          </span>
        </template>
      </a-table-column>
      
      <a-table-column title="详情" width="160px">
        <template slot-scope="row">
            <span v-for="(item, index) in  row.options" style="margin-left: 10px;">
              {{index}}:{{item}}
            </span>
        </template>
      </a-table-column>
      <a-table-column title="日期" width="60px">
        <template slot-scope="row">
          <div>{{row.created_at}}</div>
        </template>
      </a-table-column>
 
    </a-table>

  </a-modal>
</template>
<script>
  import UploadImages from '@/components/UploadImages/UploadImages'
  import iSwitch from '@/components/ISwitch/ISwitch'

  export default {
    components: {
      UploadImages,
      iSwitch,
    },
    props: {
      admin_id: 0,
    },
    data() {
      return {
        list: [],
        page: 1,
        perPage: 10,
        total: 0,
      }
    },
    watch: {
      admin_id() {
        this.initList()
      }
    },
    computed: {
      pagination() {
        return {
          defaultPageSize: this.perPage,
          defaultCurrent: this.page,
          total: this.total,
          onChange: (e) => {
            this.page = e
            this.initList()
          }
        }
      }
    },
    created() {
      this.initList()
    },
    methods: {
      initList() {
        this.$http.get(`/admin-log`, {
          params: {
            admin_id: this.admin_id,
            page: this.page,
            per_page: this.perPage,
          }
        }).then(res => {
          this.list = res.data.list
          this.total = res.data.item_total
        })
      },
      handleCancel() {
        this.$emit('refresh')
        this.$emit('cancel')
      },
    }
  }
</script>
<style lang="less" scoped>
  .cqjl{
    max-height:200px;
    overflow:overlay;
  }
  .thumb {
    width: 60px;
    height: 60px;
    border-radius: 6px;
  }
  .btn-c {
    display: flex;
    // margin-top: 30px;
    padding: 0rpx 30rpx;

    .add {}

    .save {
      margin-right: 20px;
    }

    .cancel {}
  }

  .tips {
    color: gray;
    font-size: 80%;
    margin-bottom: 10px;
  }

  a-input {
    display: inline;
  }
</style>
